Shaarli API Documentation
Shaarli's REST API.
This documentation is written according to API Blueprint specification.
-
HTML version: https://shaarli.github.io/api-documentation/
-
Git repository: https://github.com/shaarli/api-documentation
All endpoints described in this documentation must be prefixed with /api/v1/
.
Example: GET http://shaarli.domain.tld/api/v1/info
Note: all requests reaching described services must include a valid JWT token in the HTTP header. The signature must use SHA512 encryption algorithm.
The header must have use the following syntax:
Authorization: Bearer <token>
Resources:
- jwt.io and associated libraries
- Python Client
- PHP token generation example
Links ¶
Links
Links Collection ¶
List All LinksGET/links{?offset,limit,searchterm,searchtags,visibility}
Retrieve a list of links ordered by creation date, eventually filtered with parameters.
An empty array will be returned if no link is found with the filters provided.
Example URI
- offset
number
(optional) Example: 40Offset from which to start listing links (default: 0)
- limit
number
(optional) Example: 25Number of links to retrieve (default 20) or
all
. Note: usingall
can be very resource consuming with a big database, use it carefully.- searchterm
string
(optional) Example: shaarli+apiSearch terms across all links fields (url encoded string)
- searchtags
string
(optional) Example: rest+httpSearch for specifics tags. Tag list should be separated by a
+
delimitor. Set it tofalse
to retrieve only untagged links.- visibility
string
(optional) Example: privateFilter links by visibility. Allowed values:
all
,private
,public
(default:all
).
200
Body
[
{
"id": 345,
"url": "http://foo.bar",
"shorturl": "1H3Srg",
"title": "Link title",
"description": "Hello, world!",
"tags": [
"foo",
"bar"
],
"private": false,
"created": "2015-05-05T12:30:00+03:00",
"updated": "2015-05-06T14:30:00+03:00"
}
]
Schema
{
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "number",
"description": "Link identifier"
},
"url": {
"type": "string",
"description": "Link URL"
},
"shorturl": {
"type": "string",
"description": "Link permalink short URL"
},
"title": {
"type": "string",
"description": "Link title"
},
"description": {
"type": "string",
"description": "Link description"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of tags associated with the link"
},
"private": {
"type": "boolean",
"description": "This flag is set to true when a link is private"
},
"created": {
"type": "string",
"description": "Creation datetime in ISO8601 format"
},
"updated": {
"type": "string",
"description": "Link last update date in ISO8601 format"
}
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
400
Body
{
"code": 400,
"message": "Invalid parameters"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
Create a New LinkPOST/links
Create a new Link with provided request data.
Note that the shaared URL must not exists. If none is provided, a note will be created (self linked shaare).
Example URI
Headers
Content-Type: application/json
Body
{
"url": "http://foo.bar",
"title": "Link title",
"description": "Hello, world!",
"tags": [
"foo",
"bar"
],
"private": false,
"created": "2015-05-05T12:30:00+03:00",
"updated": "2015-05-06T14:30:00+03:00"
}
Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "Link URL"
},
"title": {
"type": "string",
"description": "Link title"
},
"description": {
"type": "string",
"description": "Link description"
},
"tags": {
"type": "array",
"description": "List of tags associated with the link"
},
"private": {
"type": "boolean",
"description": "This flag is set to true when a link is private"
},
"created": {
"type": "string",
"description": "Creation datetime in ISO8601 format"
},
"updated": {
"type": "string",
"description": "Link last update date in ISO8601 format"
}
}
}
201
The new link has been created, sending a redirection to the new link in Location
header.
Headers
Location: /links/345
Body
{
"id": 345,
"url": "http://foo.bar",
"shorturl": "1H3Srg",
"title": "Link title",
"description": "Hello, world!",
"tags": [
"foo",
"bar"
],
"private": false,
"created": "2015-05-05T12:30:00+03:00",
"updated": "2015-05-06T14:30:00+03:00"
}
Schema
{
"type": "object",
"properties": {
"id": {
"type": "number",
"description": "Link identifier"
},
"url": {
"type": "string",
"description": "Link URL"
},
"shorturl": {
"type": "string",
"description": "Link permalink short URL"
},
"title": {
"type": "string",
"description": "Link title"
},
"description": {
"type": "string",
"description": "Link description"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of tags associated with the link"
},
"private": {
"type": "boolean",
"description": "This flag is set to true when a link is private"
},
"created": {
"type": "string",
"description": "Creation datetime in ISO8601 format"
},
"updated": {
"type": "string",
"description": "Link last update date in ISO8601 format"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
400
Body
{
"code": 400,
"message": "Invalid parameters"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
409
Conflict: another link with the same URL has been found. The existing link is returned in the body of the response.
Body
{
"id": 345,
"url": "http://foo.bar",
"shorturl": "1H3Srg",
"title": "Link title",
"description": "Hello, world!",
"tags": [
"foo",
"bar"
],
"private": false,
"created": "2015-05-05T12:30:00+03:00",
"updated": "2015-05-06T14:30:00+03:00"
}
Schema
{
"type": "object",
"properties": {
"id": {
"type": "number",
"description": "Link identifier"
},
"url": {
"type": "string",
"description": "Link URL"
},
"shorturl": {
"type": "string",
"description": "Link permalink short URL"
},
"title": {
"type": "string",
"description": "Link title"
},
"description": {
"type": "string",
"description": "Link description"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of tags associated with the link"
},
"private": {
"type": "boolean",
"description": "This flag is set to true when a link is private"
},
"created": {
"type": "string",
"description": "Creation datetime in ISO8601 format"
},
"updated": {
"type": "string",
"description": "Link last update date in ISO8601 format"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
Link ¶
View Link detailsGET/links/{linkID}
Example URI
- linkID
number
(required) Example: 349Link identifier
200
Body
{
"id": 345,
"url": "http://foo.bar",
"shorturl": "1H3Srg",
"title": "Link title",
"description": "Hello, world!",
"tags": [
"foo",
"bar"
],
"private": false,
"created": "2015-05-05T12:30:00+03:00",
"updated": "2015-05-06T14:30:00+03:00"
}
Schema
{
"type": "object",
"properties": {
"id": {
"type": "number",
"description": "Link identifier"
},
"url": {
"type": "string",
"description": "Link URL"
},
"shorturl": {
"type": "string",
"description": "Link permalink short URL"
},
"title": {
"type": "string",
"description": "Link title"
},
"description": {
"type": "string",
"description": "Link description"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of tags associated with the link"
},
"private": {
"type": "boolean",
"description": "This flag is set to true when a link is private"
},
"created": {
"type": "string",
"description": "Creation datetime in ISO8601 format"
},
"updated": {
"type": "string",
"description": "Link last update date in ISO8601 format"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
404
Body
{
"code": 404,
"message": "Not found"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
Update a linkPUT/links/{linkID}
Update an existing link with provided request data. Keep in mind that all link’s fields will be updated.
Example URI
- linkID
number
(required) Example: 349Link identifier
Headers
Content-Type: application/json
Body
{
"url": "http://foo.bar",
"title": "Link title",
"description": "Hello, world!",
"tags": [
"foo",
"bar"
],
"private": false,
"created": "2015-05-05T12:30:00+03:00",
"updated": "2015-05-06T14:30:00+03:00"
}
Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "Link URL"
},
"title": {
"type": "string",
"description": "Link title"
},
"description": {
"type": "string",
"description": "Link description"
},
"tags": {
"type": "array",
"description": "List of tags associated with the link"
},
"private": {
"type": "boolean",
"description": "This flag is set to true when a link is private"
},
"created": {
"type": "string",
"description": "Creation datetime in ISO8601 format"
},
"updated": {
"type": "string",
"description": "Link last update date in ISO8601 format"
}
}
}
200
The existing link has been updated.
Body
{
"id": 345,
"url": "http://foo.bar",
"shorturl": "1H3Srg",
"title": "Link title",
"description": "Hello, world!",
"tags": [
"foo",
"bar"
],
"private": false,
"created": "2015-05-05T12:30:00+03:00",
"updated": "2015-05-06T14:30:00+03:00"
}
Schema
{
"type": "object",
"properties": {
"id": {
"type": "number",
"description": "Link identifier"
},
"url": {
"type": "string",
"description": "Link URL"
},
"shorturl": {
"type": "string",
"description": "Link permalink short URL"
},
"title": {
"type": "string",
"description": "Link title"
},
"description": {
"type": "string",
"description": "Link description"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of tags associated with the link"
},
"private": {
"type": "boolean",
"description": "This flag is set to true when a link is private"
},
"created": {
"type": "string",
"description": "Creation datetime in ISO8601 format"
},
"updated": {
"type": "string",
"description": "Link last update date in ISO8601 format"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
400
Body
{
"code": 400,
"message": "Invalid parameters"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
404
Body
{
"code": 404,
"message": "Not found"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
409
Conflict. Given URL already exists for another link, which is returned in the response body.
Body
{
"id": 345,
"url": "http://foo.bar",
"shorturl": "1H3Srg",
"title": "Link title",
"description": "Hello, world!",
"tags": [
"foo",
"bar"
],
"private": false,
"created": "2015-05-05T12:30:00+03:00",
"updated": "2015-05-06T14:30:00+03:00"
}
Schema
{
"type": "object",
"properties": {
"id": {
"type": "number",
"description": "Link identifier"
},
"url": {
"type": "string",
"description": "Link URL"
},
"shorturl": {
"type": "string",
"description": "Link permalink short URL"
},
"title": {
"type": "string",
"description": "Link title"
},
"description": {
"type": "string",
"description": "Link description"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of tags associated with the link"
},
"private": {
"type": "boolean",
"description": "This flag is set to true when a link is private"
},
"created": {
"type": "string",
"description": "Creation datetime in ISO8601 format"
},
"updated": {
"type": "string",
"description": "Link last update date in ISO8601 format"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
Delete a linkDELETE/links/{linkID}
Delete a link.
Example URI
- linkID
number
(required) Example: 349Link identifier
204
The existing link has been deleted.
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
404
Body
{
"code": 404,
"message": "Not found"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
Tag ¶
Get a tagGET/tags/{tagName}
Retrieve a single tag details. Provided and returned tag names are case insensitive,
meaning that the occurrences count for Tag
and tag
are added.
Example URI
- tagName
string
(required) Example: tutorialTag name
200
Body
{
"name": "Tutorial",
"occurences": 47
}
Schema
{
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the tag"
},
"occurences": {
"type": "number",
"description": "Number of links using this tag"
}
},
"required": [
"name"
],
"$schema": "http://json-schema.org/draft-04/schema#"
}
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
404
Body
{
"code": 404,
"message": "Not found"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
Update a tagPUT/tags/{tagName}
Rename a tag from the given name. If the new name you provide matches an existing tag, they will be merged.
Provided tag name is case sensitive.
Example URI
- tagName
string
(required) Example: tutorialTag name
Headers
Content-Type: application/json
Body
{
"name": "music"
}
Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the tag"
}
},
"required": [
"name"
]
}
200
The existing tag has been updated.
Body
{
"name": "Tutorial",
"occurences": 47
}
Schema
{
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the tag"
},
"occurences": {
"type": "number",
"description": "Number of links using this tag"
}
},
"required": [
"name"
],
"$schema": "http://json-schema.org/draft-04/schema#"
}
400
Body
{
"code": 400,
"message": "Invalid parameters"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
404
Body
{
"code": 404,
"message": "Not found"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
Delete a tagDELETE/tags/{tagName}
Delete a tag from every link where it is used.
Provided tag name is case sensitive.
Example URI
- tagName
string
(required) Example: tutorialTag name
204
The existing tag has been deleted.
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
404
Body
{
"code": 404,
"message": "Not found"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
History ¶
Get last user actionsGET/history{?since,offset,limit}
Retrieve the last actions made by the user, even in the web version, including:
-
CREATED
: A new link has been created. -
UPDATED
: An existing link has been updated. -
DELETED
: A link has been deleted. -
SETTINGS
: Shaarli settings have been updated.
This service can be useful to maintain a local database.
Example URI
- since
string
(optional) Example: 2015-05-05T12:30:00%2B03:00Get all event since this datetime (format ISO ISO8601). Note: the
+
should be encoded to%2B
.- offset
number
(optional) Example: 40Offset from which to start listing links (default: 0).
- limit
number
(optional) Example: 25Number of links to retrieve (default 20) or
all
.
200
Body
[
{
"event": "CREATED",
"datetime": "2015-05-05T12:30:00+03:00",
"id": 123
}
]
Schema
{
"type": "array",
"items": {
"type": "object",
"properties": {
"event": {
"type": "string",
"description": "An event code matching a user action."
},
"datetime": {
"type": "string",
"description": "Event datetime in ISO8601 format"
},
"id": {
"type": "number",
"description": "Identifier of the logged event (e.g.: created link ID)."
}
},
"required": [
"event",
"datetime"
]
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
400
Body
{
"code": 400,
"message": "Invalid parameters"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
Instance information ¶
Get instance infoGET/info
Return a list of information and settings for the Shaarli instance.
Example URI
401
Body
{
"code": 401,
"message": "Not authorized"
}
Schema
{
"type": "object",
"properties": {
"code": {
"type": "number"
},
"message": {
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
200
Body
{
"global_counter": 654,
"private_counter": 123,
"settings": {
"title": "My links",
"header_link": "https://foo.bar/shaarli",
"timezone": "Europe/Paris",
"enabled_plugins": [
"qrcode",
"markdown"
],
"default_private_links": true
}
}
Schema
{
"type": "object",
"properties": {
"global_counter": {
"type": "number",
"description": "Number of links stored in this Shaarli instance (private and public)"
},
"private_counter": {
"type": "number",
"description": "Number of private links stored"
},
"settings": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Shaarli's instance title."
},
"header_link": {
"type": "string",
"description": "Link to the homepage."
},
"timezone": {
"type": "string",
"description": "Shaarli's instance timezone."
},
"enabled_plugins": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of enabled plugins."
},
"default_private_links": {
"type": "boolean",
"description": "Check the private checkbox by default for every new link."
}
}
}
},
"required": [
"global_counter",
"private_counter"
],
"$schema": "http://json-schema.org/draft-04/schema#"
}